package com.aurora.app.entity;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.aurora.base.entity.BaseEntity;

@Entity
@Table(name="tb_thing")
public class Thing extends BaseEntity {
	//发布者
	private User user;
	//标题
	private String title;
	//出售价
	private BigDecimal cost;
	//点赞数
	private Integer zan=0;
	//过期时间
	private Date outOfTime;
	//原价
	private BigDecimal originalCost;
	//分类
	private CategoryThing category;
	//物品名字
	private String name;
	//描述
	private String describle;
	//成色 10
	private Integer NewDegree;
	//数量
	private Integer num = 1;
	//关注数量
	private Integer view =0;
	//图片
	private List<ThingImage> images;// 图片内容
	//手机
	private Long phone;
	//经纬度
	private Location location;
	
	@ManyToOne(cascade = {CascadeType.REFRESH}, optional = false, fetch = FetchType.LAZY)
	@JoinColumn(name = "f_location_id")
	public Location getLocation() {
		return location;
	}
	public void setLocation(Location location) {
		this.location = location;
	}
	@Column(name="f_phone")
	public Long getPhone() {
		return phone;
	}
	public void setPhone(Long phone) {
		this.phone = phone;
	}
	@OneToMany(fetch = FetchType.EAGER, mappedBy = "thing", cascade = {CascadeType.ALL})
	@OrderBy("createTime desc")
	public List<ThingImage> getImages() {
		return this.images;
	}
	public void setImages(List<ThingImage> images) {
		this.images = images;
	}
	
	
	
	@ManyToOne(cascade = {CascadeType.REFRESH}, optional = false, fetch = FetchType.LAZY)
	@JoinColumn(name = "f_category_id")
	public CategoryThing getCategory() {
		return category;
	}
	public void setCategory(CategoryThing category) {
		this.category = category;
	}
	@Column(name="f_name")
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	@Column(name="f_describle")
	public String getDescrible() {
		return describle;
	}
	public void setDescrible(String describle) {
		this.describle = describle;
	}
	@Column(name="f_new_degree")
	public Integer getNewDegree() {
		return NewDegree;
	}
	public void setNewDegree(Integer newDegree) {
		NewDegree = newDegree;
	}
	
	
	@ManyToOne(cascade = {CascadeType.REFRESH}, optional = false, fetch = FetchType.LAZY)
	@JoinColumn(name = "f_user_id")
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	
	@Column(name="f_title")
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	@Column(name="f_cost")
	public BigDecimal getCost() {
		return cost;
	}
	public void setCost(BigDecimal cost) {
		this.cost = cost;
	}
	@Column(name="f_zan")
	public Integer getZan() {
		return zan;
	}
	public void setZan(Integer zan) {
		this.zan = zan;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="f_out_of_time")
	public Date getOutOfTime() {
		return outOfTime;
	}
	public void setOutOfTime(Date outOfTime) {
		this.outOfTime = outOfTime;
	}
	
	@Column(name="f_origin_cost")
	public BigDecimal getOriginalCost() {
		return originalCost;
	}
	public void setOriginalCost(BigDecimal originalCost) {
		this.originalCost = originalCost;
	}
	
	@Column(name="f_num")
	public Integer getNum() {
		return num;
	}
	public void setNum(Integer num) {
		this.num = num;
	}
	
	@Column(name="f_view")
	public Integer getView() {
		return view;
	}
	public void setView(Integer view) {
		this.view = view;
	}
}
